package com.ziyia.a4_6;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    public void alertActivity(View view) {
        Intent intent = new Intent(this, MainActivity2.class);
        startActivity(intent);
    }

    public void loadLayout(View view) {
        TestFragment testFragment = new TestFragment();
        getSupportFragmentManager().beginTransaction()
                .add(R.id.frame, testFragment)
                .commit();
    }


    public void replace(View view) {
        TestFragment2 testFragment2 = new TestFragment2();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.frame, testFragment2)
                .addToBackStack("back")
                .commit();
    }

    public void finish(View view) {
        finish();
    }
}